package com.caiyi.financial.nirvana.sms.controller;


import com.caiyi.financial.nirvana.sms.entity.SmsUser;
import com.caiyi.financial.nirvana.sms.entity.SmsUserRecharge;
import com.caiyi.financial.nirvana.sms.querybean.QueryUserBean;
import com.caiyi.financial.nirvana.sms.querybean.QueryUserProductBean;
import com.caiyi.financial.nirvana.sms.querybean.UserRechargeQueryBean;
import com.caiyi.financial.nirvana.sms.service.SmsUserService;
import com.caiyi.financial.nirvana.sms.service.SmsUserSignService;
import com.youyu.common.api.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(description = "客户管理接口")
@CrossOrigin
@RestController
@RequestMapping("sms/admin/user")
public class UserController {


    @Autowired
    private SmsUserService userService;

    @Autowired
    private SmsUserSignService smsUserSignService;

    @ApiOperation(value = "更新User详情", notes = "更新User详情描述")
    @ApiImplicitParam(name = "smsUser", value = "客户实体", required = true, dataType = "SmsUser", paramType = "body")
    @PostMapping("/updateUser")
    public Result updateUser(@RequestBody SmsUser smsUser) {
        return Result.ok(userService.updateUser(smsUser));
    }

    @ApiOperation(value = "添加User详情", notes = "添加User详情描述")
    @ApiImplicitParam(name = "smsUser", value = "客户实体", required = true, dataType = "SmsUser", paramType = "body")
    @PostMapping("/addUser")
    public Result addUser(@RequestBody SmsUser smsUser) {
        return Result.ok(userService.addUser(smsUser));
    }

    @ApiOperation(value = "充值和退款列表", notes = "充值和退款列表描述")
    @ApiImplicitParams({@ApiImplicitParam(name = "bean", value = "充值查询实体", required = true, dataType = "UserRechargeQueryBean", paramType = "body")
    })
    @PostMapping("/getSmsNumList")
    public Result getSmsNumList(@RequestBody UserRechargeQueryBean bean) {
        return Result.ok(userService.getUserRechargeListByParams(bean));
    }

    @ApiOperation(value = "充值和退款详情", notes = "充值和退款详情描述")
    @ApiImplicitParams({@ApiImplicitParam(name = "userRecharge", value = "充值实体", required = true, dataType = "SmsUserRecharge", paramType = "body")
    })
    @PostMapping("/addSmsNum")
    public Result addRemindValue(@RequestBody SmsUserRecharge userRecharge) {
        return Result.ok(userService.addSmsNum(userRecharge));
    }

    @ApiOperation(value = "重新更改密码详情", notes = "重新更改密码详情描述")
    @ApiImplicitParam(name = "id", value = "用户id", dataType = "int", paramType = "query", required = true)
    @PostMapping("/updatePassword")
    public Result updatePassword(Integer id) {
        return Result.ok(userService.updatePassword(id));
    }

    @ApiOperation(value = "修改用户状态详情", notes = "修改用户状态详情描述")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户id", required = true, dataType = "int", paramType = "query")
    })
    @PostMapping("/changeStatus")
    public Result changeStatus(Integer id) {
        return Result.ok(userService.updateStatus(id));
    }

    @ApiOperation(value = "删除User详情", notes = "删除User")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "客户", dataType = "int", paramType = "query", required = true)})
    @PostMapping("/deleteUser")
    public Result deleteUser(Integer id) {
        return Result.ok(userService.deleteUser(id));
    }

    @ApiOperation(value = "根据条件查找客户详情", notes = "根据条件查找客户描述")
    @ApiImplicitParam(name = "bean", value = "查找客户参数实体", required = true, dataType = "QueryUserBean")
    @PostMapping("/getUserListByParams")
    public Result getUserList(@RequestBody QueryUserBean bean) {
        return Result.ok(userService.getUserList(bean));
    }

    @ApiOperation(value = "查找客户产品详情", notes = "查找客户产品详情详情描述")
    @ApiImplicitParam(name = "bean", value = "查找客户产品实体参数", required = true, dataType = "QueryUserProductBean")
    @PostMapping("/userProductByParams")
    public Result getUserProduct(@RequestBody QueryUserProductBean bean) {
        return Result.ok(userService.getProductListByParams(bean));
    }

    @ApiOperation(value = "显示用户密码详情", notes = "显示用户密码详情描述")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户id", required = true, dataType = "int", paramType = "query")
    })
    @PostMapping("/showPassword")
    public Result showPassword(Integer id) {
        return Result.ok(userService.showPassword(id));
    }

    @ApiOperation(value = "查询所有账号", notes = "查询所有账号描述")
    @PostMapping("/getAccountList")
    public Result getAccountList() {
        return Result.ok(userService.getAccountList());
    }


    @ApiOperation(value = "根据账号查询账户信息", notes = "根据账号查询账户信息")
    @ApiImplicitParam(name = "account", value = "账户", required = true, dataType = "String")
    @PostMapping("/getAccountInfo")
    public Result getAccountInfo(String account) {
        Result result = new Result();
        result.setData(userService.selectByAccount(account));
        return result;
    }

}
